package com.cadre.system.service.impl;

import com.cadre.common.utils.oldutil.DateUtil;
import com.cadre.system.domain.officer.*;
import com.cadre.system.mapper.*;
import com.cadre.system.service.PersonRelationService;
import com.cadre.system.service.PxRypxxxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;

@Service("personRelationService")
public class PersonRelationServiceImpl implements PersonRelationService {
    @Autowired
    private A01Mapper a01Mapper;
    @Autowired
    private A04Mapper a04Mapper;
    @Autowired
    private B01Mapper b01Mapper;
    @Autowired
    private D_PERSONTAGMapper d_PERSONTAGMapper;
    @Autowired
    private B_TAGTABMapper b_TAGTABMapper;
    @Autowired
    private A93Mapper a93Mapper;
    @Autowired
    private B01Mapper b01;
    @Autowired
    private A79Mapper a79Mapper;
    @Autowired
    private PxRypxxxService pxRypxxxService;

    public String[] getData() {
        return new String[]{"家属", "培训班", "籍贯", "同学", "服务领导"};
    }

    public D_PERSONTAG getHoster(String personid) {
        Map<String, Object> map1 = new HashMap<>();
        map1.put("personid", personid);
        map1.put("tagid", 2);
        D_PERSONTAG d_PERSONTAG = new D_PERSONTAG();
        A01 a01 = this.a01Mapper.selectByFlowid(personid);
        if (a01 != null) {
            d_PERSONTAG.setPersonid(personid);
            d_PERSONTAG.setTagid((short) 2);
            d_PERSONTAG.setValuestring(a01.getA0101());
        }
        return d_PERSONTAG;
    }

    public List<Map<String, Object>> getCategories() {
        Object[] data = getData();
        List<Map<String, Object>> categories = new ArrayList<>();
        Map<String, Object> map2 = new HashMap<>();
        map2.put("name", "人物");
        categories.add(map2);
        for (Object obj : data) {
            Map<String, Object> map21 = new HashMap<>();
            map21.put("name", obj);
            categories.add(map21);
        }
        return categories;
    }

    public PersonRelation fzHoster(String personid) {
        PersonRelation personRelation = new PersonRelation();
        D_PERSONTAG d_PERSONTAG = getHoster(personid);
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        if (d_PERSONTAG != null) {
            Map<String, Object> nodemap0 = new HashMap<>();
            nodemap0.put("category", 0);
            nodemap0.put("name", d_PERSONTAG.getValuestring());
            nodemap0.put("value", d_PERSONTAG.getTagid());
            nodemap0.put("lable", d_PERSONTAG.getValuestring() + "(主要)");
            String id = d_PERSONTAG.getPersonid();
            nodemap0.put("personid", id);
            A01 lsa01 = this.a01Mapper.selectByFlowid(id);
            if (lsa01 != null) {
                nodemap0.put("post", lsa01.getA0183());
            } else {
                nodemap0.put("post", "");
            }
            nodelist.add(nodemap0);
            Map<String, Object> linkmap = new HashMap<>();
            linkmap.put("source", d_PERSONTAG.getValuestring());
            linkmap.put("target", d_PERSONTAG.getValuestring());
            linkmap.put("weight", "1");
            linkmap.put("name", this.b_TAGTABMapper.selectTagvaluedisplay(d_PERSONTAG.getTagid()));
            linklist.add(linkmap);
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public Map<String, Object> fzNode(String nodeName, String nodePost, String id) {
        Map<String, Object> nodemap = new HashMap<>();
        nodemap.put("category", 1);
        nodemap.put("name", nodeName);
        nodemap.put("value", 30);
        nodemap.put("post", nodePost);
        nodemap.put("personid", id);
        return nodemap;
    }

    public List<Map<String, Object>> cnode(List<Map<String, Object>> nodelist, Map<String, Object> nodemap01) {
        if (!nodelist.contains(nodemap01)) {
            nodelist.add(nodemap01);
        }
        return nodelist;
    }

    public Map<String, Object> fzLink(String linkSource, String linkTarget, String linkName) {
        Map<String, Object> linkmap = new HashMap<>();
        linkmap.put("source", linkSource);
        linkmap.put("target", linkTarget);
        linkmap.put("weight", "1");
        linkmap.put("name", linkName);
        return linkmap;
    }

    public List<Map<String, Object>> clink(List<Map<String, Object>> linklist, Map<String, Object> linkmap) {
        if (!linklist.contains(linkmap)) {
            linklist.add(linkmap);
        }
        return linklist;
    }

    public List<A79> getGB(String personid) {
        return this.a79Mapper.selectByPersonid(personid);
    }

    public String getGBA01(String name, String birth, String sfz) {
        Map<String, Object> map2 = new HashMap<>();
        map2.put("A0101", name);
        map2.put("birth", birth);
        map2.put("A0107", sfz);
        List<A01> a01s = this.a01Mapper.selectByMaps(map2);
        String id = "";
        if (a01s.size() == 1) {
            id = a01s.get(0).getFlowid();
        }
        return id;
    }

    public A01 getGBA01List(String name, String birth, String sfz) {
        Map<String, Object> map2 = new HashMap<>();
        map2.put("A0101", name);
        map2.put("birth", birth);
        map2.put("A0107", sfz);
        return this.a01Mapper.selectByNameAndBirth(map2);
    }

    @Override // com.tdqy.cadre.modular.profess.service.PersonRelationService
    public A01 getGBA01List1(String name, String birth, String sfz) {
        Map<String, Object> map2 = new HashMap<>();
        map2.put("A0101", name);
        map2.put("birth", birth);
        map2.put("A0107", sfz);
        return this.a01Mapper.selectByNameAndBirth(map2);
    }

    public List<A79> getJSA79(String name, String birth, String sfz) {
        Map<String, Object> map21 = new HashMap<>();
        map21.put("name", name);
        map21.put("birth", birth);
        map21.put("sfz", sfz);
        return this.a79Mapper.selectByNameAndBirth(map21);
    }

    public Map<String, List<Map<String, Object>>> selectFaMsg(String personid, List<Map<String, Object>> linklist, List<Map<String, Object>> nodelist, D_PERSONTAG d_PERSONTAG) {
        List<A79> a79list = this.a79Mapper.selectByPersonid(personid);
        getA79ByA01(linklist, nodelist, (A01) this.a01Mapper.selectById(personid));
        if (a79list.size() > 0) {
            for (int i = 0; i < a79list.size(); i++) {
                String name = a79list.get(i).getA7921();
                String birth = DateUtil.dateToString(a79list.get(i).getA7922(), "yyyy-MM");
                A01 a01 = getGBA01List(name, birth, a79list.get(i).getA7913());
                if (a01 != null) {
                    nodelist = cnode(nodelist, fzNode(name, a01.getA0183(), a01.getFlowid()));
                    String linkSource = a79list.get(i).getA7921();
                    String linkTarget = d_PERSONTAG.getValuestring();
                    linklist = clink(linklist, fzLink(linkSource, linkTarget, linkTarget + "的" + a79list.get(i).getA7910()));
                    getImportantFamily(linklist, nodelist, a79list.get(i));
                } else {
                    String nodePost = a79list.get(i).getA7923();
                    if (!birth.equals("")) {
                        List<A79> a79sk = getJSA79(name, birth, a79list.get(i).getA7913());
                        String a79listPersonid = a79list.get(i).getPersonid();
                        if (a79sk.size() > 0) {
                            for (int k = 0; k < a79sk.size(); k++) {
                                if (a79sk.get(k).getPersonid().equals(a79listPersonid)) {
                                    nodelist = cnode(nodelist, fzNode(name, nodePost, ""));
                                    String linkSource2 = a79list.get(i).getA7921();
                                    String linkTarget2 = d_PERSONTAG.getValuestring();
                                    linklist = clink(linklist, fzLink(linkSource2, linkTarget2, linkTarget2 + "的" + a79list.get(i).getA7910()));
                                    if (!birth.equals("")) {
                                        getImportantFamily(linklist, nodelist, a79sk.get(k));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        Map<String, List<Map<String, Object>>> map = new HashMap<>();
        map.put("nodelist", nodelist);
        map.put("linklist", linklist);
        return map;
    }

    private void getImportantFamily(List<Map<String, Object>> linklist, List<Map<String, Object>> nodelist, A79 a79) {
        A01 a01a;
        String importantName = a79.getA7921();
        if (importantName != null) {
            List<A79> a79listk = getJSA79(importantName, DateUtil.dateToString(a79.getA7922(), "yyyy-MM"), a79.getA7913());
            if (a79listk.size() > 0) {
                for (int j = 0; j < a79listk.size(); j++) {
                    String a79listkPersonid = a79listk.get(j).getPersonid();
                    if (!a79.getPersonid().equals(a79listkPersonid) && (a01a = this.a01Mapper.selectZaizhiByFlowid(a79listkPersonid)) != null) {
                        String nodeName2 = a01a.getA0101();
                        nodelist = cnode(nodelist, fzNode(nodeName2, a01a.getA0183(), a01a.getFlowid()));
                        String linkName2 = "";
                        List<A79> a79s = getGB(a79listkPersonid);
                        if (a79s.size() > 0) {
                            for (int l = 0; l < a79s.size(); l++) {
                                if (a79s.get(l).getA7921() != null && a79s.get(l).getA7921().equals(importantName)) {
                                    linkName2 = a79s.get(l).getA7910();
                                }
                            }
                        }
                        linklist = clink(linklist, fzLink(nodeName2, importantName, nodeName2 + "的" + linkName2));
                    }
                }
            }
        }
    }

    private void getA79ByA01(List<Map<String, Object>> linklist, List<Map<String, Object>> nodelist, A01 a) {
        String importantName = a.getA0101();
        List<A79> a79listk = getJSA79(importantName, DateUtil.dateToString(a.getA0106(), "yyyy-MM"), a.getA0107());
        if (a79listk.size() > 1) {
            for (int j = 0; j < a79listk.size(); j++) {
                String a79listkPersonid = a79listk.get(j).getPersonid();
                A01 a01a = this.a01Mapper.selectByFlowid(a79listkPersonid);
                if (a01a != null) {
                    String nodeName2 = a01a.getA0101();
                    nodelist = cnode(nodelist, fzNode(nodeName2, a01a.getA0183(), a01a.getFlowid()));
                    String linkName2 = "";
                    List<A79> a79s = getGB(a79listkPersonid);
                    if (a79s.size() > 0) {
                        for (int l = 0; l < a79s.size(); l++) {
                            if (a79s.get(l).getA7921().equals(importantName)) {
                                linkName2 = a79s.get(l).getA7910();
                            }
                        }
                    }
                    linklist = clink(linklist, fzLink(nodeName2, importantName, nodeName2 + "的" + linkName2));
                }
            }
        }
    }

    public PersonRelation fzFaMsg(String personid) {
        PersonRelation personRelation = new PersonRelation();
        D_PERSONTAG d_PERSONTAG = getHoster(personid);
        Map<String, List<Map<String, Object>>> map = selectFaMsg(personid, new ArrayList<>(), new ArrayList<>(), d_PERSONTAG);
        personRelation.setNode(map.get("nodelist"));
        personRelation.setLinks(map.get("linklist"));
        return personRelation;
    }

    public PersonRelation fzPxbMsg(String personid) {
        PersonRelation personRelation = new PersonRelation();
        D_PERSONTAG d_PERSONTAG = getHoster(personid);
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        List<PxRypxxxEntity> pxbList = this.pxRypxxxService.selectByPxb(personid);
        if (pxbList != null && pxbList.size() > 0) {
            for (int j = 0; j < pxbList.size(); j++) {
                String id011 = "-1";
                try {
                    id011 = pxbList.get(j).getPersonid() == null ? "-1" : pxbList.get(j).getPersonid();
                } catch (Exception e) {
                }
                A01 lsa011 = this.a01Mapper.selectZaizhiByFlowid(id011);
                Map<String, Object> nodemap01 = new HashMap<>();
                nodemap01.put("category", 2);
                nodemap01.put("name", lsa011 == null ? "" : lsa011.getA0101());
                nodemap01.put("value", 169);
                nodemap01.put("personid", id011);
                if (lsa011 != null) {
                    nodemap01.put("post", lsa011.getA0183());
                    nodelist.add(nodemap01);
                    Map<String, Object> linkmap1 = new HashMap<>();
                    linkmap1.put("source", lsa011 == null ? "" : lsa011.getA0101());
                    linkmap1.put("target", d_PERSONTAG.getValuestring());
                    linkmap1.put("weight", "2");
                    linkmap1.put("name", "同培训班");
                    linkmap1.put("type", "培训班");
                    linkmap1.put("id", UUID.randomUUID().toString());
                    linklist.add(linkmap1);
                } else {
                    nodemap01.put("post", "");
                }
            }
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzJgMsg(String personid, A01 host) {
        Object a0108;
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        if (!(host == null || null == (a0108 = host.getA0108()) || "其他".equals(a0108))) {
            Map<String, Object> map = new HashMap<>();
            map.put("A0108", a0108);
            List<A01> a01s = this.a01Mapper.selectList(map);
            if (a01s.size() > 0) {
                for (int j = 0; j < a01s.size(); j++) {
                    A01 a01 = a01s.get(j);
                    Map<String, Object> nodemap01 = new HashMap<>();
                    if (a01 != null && !a01.getFlowid().equals(personid)) {
                        nodemap01.put("category", 3);
                        nodemap01.put("name", a01.getA0101());
                        nodemap01.put("value", "2");
                        nodemap01.put("personid", a01.getFlowid());
                        nodemap01.put("post", a01.getA0183());
                        nodelist.add(nodemap01);
                        Map<String, Object> linkmap1 = new HashMap<>();
                        linkmap1.put("source", a01.getA0101());
                        linkmap1.put("target", host.getA0101());
                        linkmap1.put("weight", "2");
                        linkmap1.put("name", "同籍贯");
                        linkmap1.put("type", "籍贯");
                        linkmap1.put("id", UUID.randomUUID().toString());
                        linklist.add(linkmap1);
                    } else {
                        nodemap01.put("post", "");
                    }
                }
            }
            personRelation.setNode(nodelist);
            personRelation.setLinks(linklist);
        }
        return personRelation;
    }

    public PersonRelation fzTxMsg(String personid, A01 host) {
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("personid", personid);
        List<A04> a04list = this.a04Mapper.selectByPersonid(map);
        if (a04list.size() > 0) {
            Object A0411 = a04list.get(0).getA0411();
            Object A0435 = a04list.get(0).getA0435();
            String endtime = DateUtil.dateToString(a04list.get(0).getA0430(), "yyyy-MM-dd");
            String starttime = DateUtil.dateToString(a04list.get(0).getA0415(), "yyyy-MM-dd");
            Map<String, Object> map2 = new HashMap<>();
            map2.put("A0411", A0411);
            map2.put("A0435", A0435);
            map2.put("endtime", endtime.toString());
            map2.put("starttime", starttime.toString());
            List<A04> a04s = this.a04Mapper.selectByTxPerson(map2);
            if (a04s.size() > 0) {
                for (int i = 0; i < a04s.size(); i++) {
                    A01 a01 = this.a01Mapper.selectZaizhiByFlowid(a04s.get(i).getPersonid());
                    if (a01 != null) {
                        Map<String, Object> nodemap01 = new HashMap<>();
                        nodemap01.put("category", 4);
                        nodemap01.put("name", a01.getA0101());
                        nodemap01.put("value", "");
                        nodemap01.put("personid", a01.getFlowid());
                        nodemap01.put("post", a01.getA0183());
                        nodelist.add(nodemap01);
                        Map<String, Object> linkmap1 = new HashMap<>();
                        linkmap1.put("source", a01.getA0101());
                        linkmap1.put("target", host.getA0101());
                        linkmap1.put("weight", "2");
                        linkmap1.put("name", "同学");
                        linkmap1.put("type", "同学");
                        linkmap1.put("id", UUID.randomUUID().toString());
                        linklist.add(linkmap1);
                    }
                }
            }
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzTsMsg(String personid) {
        PersonRelation personRelation = new PersonRelation();
        D_PERSONTAG d_PERSONTAG = getHoster(personid);
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        List<D_PERSONTAG> tsList = this.d_PERSONTAGMapper.selectByTs(personid);
        if (tsList.size() > 0) {
            for (int j = 0; j < tsList.size(); j++) {
                Map<String, Object> nodemap01 = new HashMap<>();
                nodemap01.put("category", 5);
                nodemap01.put("name", tsList.get(j).getValuestring());
                nodemap01.put("value", tsList.get(j).getTagid());
                nodemap01.put("personid", tsList.get(j).getPersonid());
                A01 lsa011 = this.a01Mapper.selectByFlowid(tsList.get(j).getPersonid());
                if (lsa011 != null) {
                    nodemap01.put("post", lsa011.getA0183());
                } else {
                    nodemap01.put("post", "");
                }
                nodelist.add(nodemap01);
                Map<String, Object> linkmap1 = new HashMap<>();
                linkmap1.put("source", tsList.get(j).getValuestring());
                linkmap1.put("target", d_PERSONTAG.getValuestring());
                linkmap1.put("weight", "5");
                linkmap1.put("name", "同事");
                linkmap1.put("id", UUID.randomUUID().toString());
                linklist.add(linkmap1);
            }
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzMsMsg(String personid) {
        PersonRelation personRelation = new PersonRelation();
        A01 a01 = this.a01Mapper.selectByFlowid(personid);
        String name = "";
        if (a01 != null) {
            name = a01.getA0101().toString();
        }
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("personid", personid);
        List<A93> list = this.a93Mapper.selectByMaps(map);
        if (list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Map<String, Object> map1 = new HashMap<>();
                map1.put("A0101", list.get(i).getA9305());
                map1.put("A0183", list.get(i).getPost());
                if (this.a01Mapper.selectByNameAndZhiwu(map1) != null) {
                    Map<String, Object> nodemap01 = new HashMap<>();
                    nodemap01.put("category", 5);
                    nodemap01.put("name", list.get(i).getA9305());
                    nodemap01.put("value", "");
                    nodemap01.put("personid", "");
                    nodemap01.put("post", list.get(i).getPost());
                    nodelist.add(nodemap01);
                    Map<String, Object> linkmap1 = new HashMap<>();
                    linkmap1.put("source", list.get(i).getA9305());
                    linkmap1.put("target", name);
                    linkmap1.put("weight", "6");
                    linkmap1.put("name", "服务领导");
                    linkmap1.put("type", "服务领导");
                    linkmap1.put("id", UUID.randomUUID().toString());
                    linklist.add(linkmap1);
                }
            }
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzFwLdMsg(String personid) {
        PersonRelation personRelation = new PersonRelation();
        D_PERSONTAG d_PERSONTAG = getHoster(personid);
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("personid", personid);
        List<A01> list = this.a93Mapper.selectToLeaders(map);
        if (list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Map<String, Object> nodemap01 = new HashMap<>();
                nodemap01.put("category", 7);
                nodemap01.put("name", list.get(i).getA0101());
                nodemap01.put("value", "");
                nodemap01.put("personid", "");
                List<A79> a79s = this.a79Mapper.selectByName(list.get(i).getA0101());
                if (a79s.size() > 0) {
                    nodemap01.put("post", a79s.get(0).getA7923());
                } else {
                    nodemap01.put("post", "");
                }
                nodelist.add(nodemap01);
                Map<String, Object> linkmap1 = new HashMap<>();
                linkmap1.put("source", list.get(i).getA0101());
                linkmap1.put("target", d_PERSONTAG.getValuestring());
                linkmap1.put("weight", "7");
                linkmap1.put("name", "服务领导");
                linkmap1.put("type", "服务领导");
                linkmap1.put("id", UUID.randomUUID().toString());
                linklist.add(linkmap1);
            }
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation getMsg(String personid) {
        PersonRelation personRelation = fzHoster(personid);
        A01 host = this.a01Mapper.selectByFlowid(personid);
        if (personRelation != null) {
            personRelation.setCategories(getCategories());
            personRelation.setData(getData());
            personRelation.setSubtext("");
            personRelation.setText(getHoster(personid).getValuestring());
            PersonRelation Fa = fzFaMsg(personid);
            List<Map<String, Object>> FaNode = Fa.getNode();
            List<Map<String, Object>> FaLink = Fa.getLinks();
            if (FaNode != null) {
                personRelation.getNode().addAll(FaNode);
            }
            if (FaLink != null) {
                personRelation.getLinks().addAll(FaLink);
            }
            PersonRelation Pxb = fzPxbMsg(personid);
            List<Map<String, Object>> PxbNode = Pxb.getNode();
            List<Map<String, Object>> PxbLink = Pxb.getLinks();
            if (PxbNode != null) {
                personRelation.getNode().addAll(PxbNode);
            }
            if (PxbLink != null) {
                personRelation.getLinks().addAll(PxbLink);
            }
            long time1 = System.currentTimeMillis();
            PersonRelation Jg = fzJgMsg(personid, host);
            System.out.println((System.currentTimeMillis() - time1) + "%%%%%%%%%%%%%%%%%%%%%%%%%%%");
            List<Map<String, Object>> JgNode = Jg.getNode();
            List<Map<String, Object>> JgLink = Jg.getLinks();
            if (JgNode != null) {
                personRelation.getNode().addAll(JgNode);
            }
            if (JgLink != null) {
                personRelation.getLinks().addAll(JgLink);
            }
            PersonRelation Tx = fzTxMsg(personid, host);
            List<Map<String, Object>> TxNode = Tx.getNode();
            List<Map<String, Object>> TxLink = Tx.getLinks();
            if (TxNode != null) {
                personRelation.getNode().addAll(TxNode);
            }
            if (TxLink != null) {
                personRelation.getLinks().addAll(TxLink);
            }
            PersonRelation Ms = fzMsMsg(personid);
            List<Map<String, Object>> MsNode = Ms.getNode();
            List<Map<String, Object>> MsLink = Ms.getLinks();
            if (MsNode != null) {
                personRelation.getNode().addAll(MsNode);
            }
            if (MsLink != null) {
                personRelation.getLinks().addAll(MsLink);
            }
        }
        return personRelation;
    }

    @Override // com.tdqy.cadre.modular.profess.service.PersonRelationService
    public PersonRelation getRelation(String personid) {
        return getMsg(personid);
    }

    @Override // com.tdqy.cadre.modular.profess.service.PersonRelationService
    public PersonRelation getBzRelation(String unitId) {
        PersonRelation personRelation2;
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> nodelist = new ArrayList<>();
        new ArrayList();
        B01 b = (B01) this.b01.selectById(unitId);
        personRelation.setCategories(getCategories());
        personRelation.setData(new String[]{"家属", "培训班", "籍贯", "同学", "秘书"});
        personRelation.setSubtext(b.getB0101());
        personRelation.setText(b.getB0101());
        List<TeamMember> list = this.b01Mapper.getteamByFlowid(unitId);
        if (list.size() > 0) {
            for (TeamMember teamMember : list) {
                if (!(teamMember == null || teamMember.getXm() == null)) {
                    Map<String, Object> nodemap0 = new HashMap<>();
                    nodemap0.put("category", 0);
                    nodemap0.put("name", teamMember.getXm());
                    nodemap0.put("value", "2");
                    nodemap0.put("lable", teamMember.getXm());
                    nodemap0.put("personid", teamMember.getFlowid());
                    nodelist.add(nodemap0);
                }
            }
        }
        personRelation.setNode(nodelist);
        List<String> flowIdList = new ArrayList<>();
        for (TeamMember t : list) {
            if (!(t == null || t.getFlowid() == null)) {
                flowIdList.add(t.getFlowid());
            }
        }
        if (flowIdList.size() > 0 && (personRelation2 = getBzMsg(flowIdList)) != null) {
            personRelation.getNode().addAll(personRelation2.getNode());
            personRelation.setLinks(personRelation2.getLinks());
        }
        return personRelation;
    }

    public PersonRelation getBzMsg(List<String> flowIdList) {
        PersonRelation personRelation = fzFaMsg_BZ(flowIdList);
        if (personRelation != null) {
            personRelation.getLinks().addAll(fzPxbMsg_BZ(flowIdList).getLinks());
            personRelation.getLinks().addAll(fzJgMsg_BZ(flowIdList).getLinks());
            personRelation.getLinks().addAll(fzTxMsg_BZ(flowIdList).getLinks());
            PersonRelation personRelation5 = fzMsMsg_BZ(flowIdList);
            if (personRelation.getLinks() == null) {
                personRelation.setLinks(personRelation5.getLinks());
            } else {
                personRelation.getLinks().addAll(personRelation5.getLinks());
            }
            personRelation.getNode().addAll(personRelation5.getNode());
        }
        return personRelation;
    }

    public PersonRelation fzFaMsg_BZ(List<String> flowIdList) {
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        List<D_PERSONTAG_BZ> faList = this.d_PERSONTAGMapper.selectByFamily_BZ(flowIdList);
        if (faList.size() > 0) {
            for (int j = 0; j < faList.size(); j++) {
                for (int k = 0; k < faList.size(); k++) {
                    if (!faList.get(k).getPersonid().equals(faList.get(j).getPersonid()) && faList.get(k).getValuestring().equals(faList.get(j).getValuestring())) {
                        Map<String, Object> nodemap01 = new HashMap<>();
                        nodemap01.put("category", 1);
                        nodemap01.put("name", faList.get(j).getValuestring());
                        nodemap01.put("value", faList.get(j).getTagid());
                        nodemap01.put("personid", this.a01Mapper.selectByName(faList.get(j).getValuestring()));
                        nodelist.add(nodemap01);
                        Map<String, Object> linkmap1 = new HashMap<>();
                        linkmap1.put("source", faList.get(j).getValuestring());
                        linkmap1.put("target", faList.get(j).getXm());
                        linkmap1.put("weight", "2");
                        linkmap1.put("name", this.b_TAGTABMapper.selectTagvaluedisplay(faList.get(j).getTagid()));
                        linkmap1.put("type", "家属");
                        linkmap1.put("id", UUID.randomUUID().toString());
                        linklist.add(linkmap1);
                        String uuid = this.d_PERSONTAGMapper.selectByFamilyUUID(faList.get(j).getValuestring());
                        if (!(uuid == null || uuid == "")) {
                            List<D_PERSONTAG_BZ> faList02 = this.d_PERSONTAGMapper.selectByFamily_BZ(flowIdList);
                            if (faList02.size() > 0) {
                                for (int i = 0; i < faList02.size(); i++) {
                                    Map<String, Object> nodemap011 = new HashMap<>();
                                    nodemap011.put("category", 1);
                                    nodemap011.put("name", faList02.get(i).getValuestring());
                                    nodemap011.put("value", faList02.get(i).getTagid());
                                    nodemap011.put("personid", this.a01Mapper.selectByName(faList02.get(i).getValuestring()));
                                    nodelist.add(nodemap011);
                                    Map<String, Object> linkmap11 = new HashMap<>();
                                    linkmap11.put("source", faList02.get(i).getValuestring());
                                    linkmap11.put("target", faList.get(j).getXm());
                                    linkmap11.put("weight", "2");
                                    linkmap11.put("name", this.b_TAGTABMapper.selectTagvaluedisplay(faList02.get(i).getTagid()));
                                    linklist.add(linkmap11);
                                }
                            }
                        }
                    }
                }
            }
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzPxbMsg_BZ(List<String> flowIdList) {
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> linklist = new ArrayList<>();
        List<D_PERSONTAG_BZ> pxbList = this.d_PERSONTAGMapper.selectByPxb_BZ(flowIdList);
        if (pxbList.size() > 0) {
            for (int j = 0; j < pxbList.size(); j++) {
                for (int k = 0; k < pxbList.size(); k++) {
                    if (pxbList.get(k).getPersonid().equals(pxbList.get(j).getPersonid()) && pxbList.get(k).getValuestring().equals(pxbList.get(j).getValuestring())) {
                        Map<String, Object> linkmap1 = new HashMap<>();
                        linkmap1.put("source", pxbList.get(j).getValuestring());
                        linkmap1.put("target", pxbList.get(j).getXm());
                        linkmap1.put("weight", "2");
                        linkmap1.put("name", this.b_TAGTABMapper.selectTagvaluedisplay(pxbList.get(j).getTagid()));
                        linkmap1.put("type", "培训班");
                        linkmap1.put("id", UUID.randomUUID().toString());
                        linklist.add(linkmap1);
                    }
                }
            }
        }
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzJgMsg_BZ(List<String> flowIdList) {
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> linklist = new ArrayList<>();
        List<D_PERSONTAG_BZ> jgList = this.d_PERSONTAGMapper.selectByJg_BZ(flowIdList);
        if (jgList.size() > 0) {
            for (int j = 0; j < jgList.size(); j++) {
                for (int k = 0; k < jgList.size(); k++) {
                    if (jgList.get(k).getPersonid().equals(jgList.get(j).getPersonid()) && jgList.get(k).getValuestring().equals(jgList.get(j).getValuestring())) {
                        Map<String, Object> linkmap1 = new HashMap<>();
                        linkmap1.put("source", jgList.get(j).getValuestring());
                        linkmap1.put("target", jgList.get(j).getXm());
                        linkmap1.put("weight", "2");
                        linkmap1.put("name", this.b_TAGTABMapper.selectTagvaluedisplay(jgList.get(j).getTagid()));
                        linkmap1.put("type", "籍贯");
                        linkmap1.put("id", UUID.randomUUID().toString());
                        linklist.add(linkmap1);
                    }
                }
            }
        }
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzTxMsg_BZ(List<String> flowIdList) {
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> linklist = new ArrayList<>();
        List<D_PERSONTAG_BZ> txList = this.d_PERSONTAGMapper.selectByTx_BZ(flowIdList);
        if (txList.size() > 0) {
            for (int j = 0; j < txList.size(); j++) {
                for (int k = 0; k < txList.size(); k++) {
                    if (txList.get(k).getPersonid().equals(txList.get(j).getPersonid()) && txList.get(k).getValuestring() != null && txList.get(k).getValuestring().equals(txList.get(j).getValuestring())) {
                        Map<String, Object> linkmap1 = new HashMap<>();
                        linkmap1.put("source", txList.get(j).getValuestring());
                        linkmap1.put("target", txList.get(j).getXm());
                        linkmap1.put("weight", "2");
                        linkmap1.put("name", this.b_TAGTABMapper.selectTagvaluedisplay(txList.get(j).getTagid()));
                        linkmap1.put("type", "同学");
                        linkmap1.put("id", UUID.randomUUID().toString());
                        linklist.add(linkmap1);
                    }
                }
            }
        }
        personRelation.setLinks(linklist);
        return personRelation;
    }

    public PersonRelation fzMsMsg_BZ(List<String> flowIdList) {
        PersonRelation personRelation = new PersonRelation();
        List<Map<String, Object>> nodelist = new ArrayList<>();
        List<Map<String, Object>> linklist = new ArrayList<>();
        List<A93_BZ> list = this.a93Mapper.selectByMaps_BZ(flowIdList);
        if (list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).getA9305() != null) {
                    for (int n = 0; n < list.size(); n++) {
                        if (!list.get(n).getXm().equals(list.get(i).getXm()) && list.get(n).getA9305().equals(list.get(i).getA9305())) {
                            Map<String, Object> nodemap01 = new HashMap<>();
                            nodemap01.put("category", 6);
                            nodemap01.put("name", list.get(i).getA9305());
                            nodemap01.put("value", "");
                            nodemap01.put("personid", "");
                            nodelist.add(nodemap01);
                            Map<String, Object> linkmap1 = new HashMap<>();
                            linkmap1.put("source", list.get(i).getA9305());
                            linkmap1.put("target", list.get(i).getXm());
                            linkmap1.put("weight", "6");
                            linkmap1.put("name", "秘书");
                            linkmap1.put("id", UUID.randomUUID().toString());
                            linklist.add(linkmap1);
                        }
                    }
                }
            }
        }
        personRelation.setNode(nodelist);
        personRelation.setLinks(linklist);
        return personRelation;
    }

    private PersonRelation combineSydwCore(PersonRelation sourceBean, PersonRelation targetBean) {
        Class sourceBeanClass = sourceBean.getClass();
        Class targetBeanClass = targetBean.getClass();
        Field[] sourceFields = sourceBeanClass.getDeclaredFields();
        Field[] targetFields = targetBeanClass.getDeclaredFields();
        for (int i = 0; i < sourceFields.length; i++) {
            Field sourceField = sourceFields[i];
            if (!Modifier.isStatic(sourceField.getModifiers())) {
                Field targetField = targetFields[i];
                if (!Modifier.isStatic(targetField.getModifiers())) {
                    sourceField.setAccessible(true);
                    targetField.setAccessible(true);
                    try {
                        if (sourceField.get(sourceBean) != null && !"serialVersionUID".equals(sourceField.getName().toString())) {
                            targetField.set(targetBean, sourceField.get(sourceBean));
                        }
                    } catch (IllegalAccessException | IllegalArgumentException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return targetBean;
    }

    @Override // com.tdqy.cadre.modular.profess.service.PersonRelationService
    public PersonRelation getRelation(String personid, String tag) {
        return null;
    }
}
